package com.etc.test3.cglib;



import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;


/**
 * @author MaZheng
 * @since 2020/12/23 - 16:41
 */
public class ProxyToolsMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        Object obj = null;
        try {
            System.out.println("___________前置_____________");

            obj = methodProxy.invokeSuper(o, objects);
            System.out.println("___________后置_____________");
        } catch (Exception e) {
           e.printStackTrace();
            System.out.println("__________异常____");
        } finally {
            System.out.println("__________finally____");
        }
        return obj;
    }
}
